package summary;

import java.util.LinkedList;

/**
 * @Author: 海琳琦
 * @Date: 2022/3/10 15:15
 * https://leetcode-cn.com/problems/implement-stack-using-queues/
 */
public class Title225Plus {

    LinkedList<Integer> list;

    int size;

    public Title225Plus() {
        list = new LinkedList<>();
    }

    public void push(int x) {
        list.offer(x);
        size++;
    }

    public int pop() {
        int temp = size;
        while (size-- != 1) {
            list.offer(list.poll());
        }
        size = temp - 1;
        return list.peek();
    }

    public int top() {
        //如果peekLast合法
        return list.peekLast();
    }

    public boolean empty() {
        return list.isEmpty();
    }

    public static void main(String[] args) {

    }
}
